/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Client_GUI.SavingBook;

import Client_GUI.Unity;
import Interface.*;
import Server.*;
import Server.DTO.Deposit_DTO;
import Server.DTO.SavingBook_DTO;
import java.awt.event.KeyEvent;
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.sql.Date;
import java.text.SimpleDateFormat;
import javax.swing.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.swingx.JXDatePicker;

/**
 *
 * @author 10520_000
 */
public class JP_Deposit extends org.jdesktop.swingx.JXPanel {

    Registry registry;
    IRemoteSavingBook rsavingbook;
    IRemoteCustomer rcustomer;
    IRemoteSavingType rsavingtype;
    IRemoteDeposit rdeposit;
    IRemoteParameter rparamater;
    ArrayList arr_Names = null;
    ArrayList arr_Terms = null;

    /**
     * CreatesJP_SavingTypeAddCusomerAddCusomer
     */
    public JP_Deposit(Deposit_DTO info) throws RemoteException, NotBoundException {
        initComponents();
        registry = LocateRegistry.getRegistry("127.0.0.1");
        rsavingbook = (IRemoteSavingBook) registry.lookup("SavingBook");
        rcustomer = (IRemoteCustomer) registry.lookup("Customer");
        rsavingtype = (IRemoteSavingType) registry.lookup("SavingType");
        rparamater = (IRemoteParameter) registry.lookup("Parameter");
        rdeposit = (IRemoteDeposit) registry.lookup("Deposit");
        //gan loai tiet kiem vao combobox
        cbo_TenLoaiTietKiem.addItem("CO KY HAN");
        //gan ky han vao combobox
        arr_Terms = rsavingtype.GetTerms();

        for (int i = 0; i < arr_Terms.size(); i++) {
            if (((Integer) arr_Terms.get(i)).intValue() == 0) {
                cbo_KyHan.addItem("Khong Ky Han");
            } else {
                cbo_KyHan.addItem(arr_Terms.get(i) + " Thang");
            }

        }

        if (cbo_TenLoaiTietKiem.getSelectedItem().toString().trim().compareTo("khong ky han") != 0) {
            cbo_KyHan.removeItem("Khong Ky Han");
        } else {

        }

        //gan ngay mac dinh
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat dayFormat = new SimpleDateFormat("dd/MM/yyyy");
        JXNgayMo.setDate(date);
        //
        //ArrayList arr = rsavingtype.GetNames();
        txt_HotenNguoiGui.setText(info.getCustomerName());
        txt_SoCMNDNguoiGui.setText(info.getIDNumber());
        txt_TenNguoiThuHuong.setText(info.getBeneficiaryName());
        txt_CMNDNguoiThuHuong.setText(info.getIDNumberBeneficiary());
    }

    public Date ConvertDateSQL(JXDatePicker date) {
        return new Date(date.getDate().getYear(), date.getDate().getMonth(), date.getDate().getDate());
    }

    public Date DateAfterCurrentDate(Date date, int month) {
        return new Date(date.getYear(), date.getMonth() + month, date.getDate());
    }

    public void ClearAll() {
        this.txt_HotenNguoiGui.setText("");
        this.txt_SoCMNDNguoiGui.setText("");
        this.cbo_TenLoaiTietKiem.setSelectedItem(cbo_TenLoaiTietKiem.getItemAt(0));
        this.cbo_KyHan.setSelectedItem(cbo_KyHan.getItemAt(0));
        //this.txt_SoTienGuiBanDau.setText("");
        this.JXNgayMo.setDate(new java.util.Date());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txt_HotenNguoiGui = new javax.swing.JTextField();
        txt_SoCMNDNguoiGui = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        JXNgayMo = new org.jdesktop.swingx.JXDatePicker();
        jLabel8 = new javax.swing.JLabel();
        txt_TenNguoiThuHuong = new javax.swing.JTextField();
        txt_CMNDNguoiThuHuong = new javax.swing.JTextField();
        cbo_TenLoaiTietKiem = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        cbo_KyHan = new javax.swing.JComboBox();
        jLabel10 = new javax.swing.JLabel();
        txt_SoTienGui = new javax.swing.JTextField();
        btn_Them = new javax.swing.JButton();
        btn_NhapLai = new javax.swing.JButton();
        btn_thoat = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin khách hàng"));

        jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel2.setText("Tên Người Gửi");

        txt_HotenNguoiGui.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        txt_HotenNguoiGui.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_HotenNguoiGuiKeyTyped(evt);
            }
        });

        txt_SoCMNDNguoiGui.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        txt_SoCMNDNguoiGui.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_SoCMNDNguoiGuiKeyTyped(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel3.setText("Số CMND Người Gửi");

        jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel4.setText("Tên Người Thụ Hưởng");

        jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel5.setText("Tên Loại Tiết Kiệm");

        jLabel6.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N

        jLabel7.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel7.setText("Số CMND Người Thụ Hưởng");

        jLabel8.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel8.setText("Ngày Mở");

        txt_TenNguoiThuHuong.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        txt_TenNguoiThuHuong.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_TenNguoiThuHuongKeyTyped(evt);
            }
        });

        txt_CMNDNguoiThuHuong.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        txt_CMNDNguoiThuHuong.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_CMNDNguoiThuHuongKeyTyped(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel9.setText("Kỳ Hạn");

        jLabel10.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        jLabel10.setText("Số Tiền Gửi");

        txt_SoTienGui.setFont(new java.awt.Font("Times New Roman", 0, 15)); // NOI18N
        txt_SoTienGui.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txt_SoTienGuiKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(129, 129, 129)
                        .addComponent(txt_SoTienGui, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel6)
                                        .addComponent(jLabel2)
                                        .addComponent(jLabel4)
                                        .addComponent(jLabel3))
                                    .addGap(72, 72, 72))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLabel7)
                                            .addGap(0, 0, Short.MAX_VALUE))
                                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(153, 153, 153)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbo_KyHan, 0, 205, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txt_HotenNguoiGui, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                .addComponent(txt_SoCMNDNguoiGui, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                .addComponent(JXNgayMo, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                .addComponent(txt_TenNguoiThuHuong)
                                .addComponent(txt_CMNDNguoiThuHuong, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                                .addComponent(cbo_TenLoaiTietKiem, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addGap(41, 41, 41))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txt_HotenNguoiGui, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txt_SoCMNDNguoiGui, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_TenNguoiThuHuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txt_CMNDNguoiThuHuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addGap(5, 5, 5)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(cbo_TenLoaiTietKiem, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(cbo_KyHan, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(txt_SoTienGui, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8)
                    .addComponent(JXNgayMo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        btn_Them.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/32/Small_AddCustomer.png"))); // NOI18N
        btn_Them.setText("Thêm ");
        btn_Them.setToolTipText("");
        btn_Them.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btn_Them.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btn_Them.setIconTextGap(40);
        btn_Them.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ThemActionPerformed(evt);
            }
        });

        btn_NhapLai.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/32/Small_Update.png"))); // NOI18N
        btn_NhapLai.setText("Nhập lại");
        btn_NhapLai.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btn_NhapLai.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btn_NhapLai.setIconTextGap(40);
        btn_NhapLai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_NhapLaiActionPerformed(evt);
            }
        });

        btn_thoat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/image/32/Small_Close.png"))); // NOI18N
        btn_thoat.setText("Thoát");
        btn_thoat.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btn_thoat.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btn_thoat.setIconTextGap(40);
        btn_thoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_thoatActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btn_Them, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_NhapLai, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_thoat, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(66, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(btn_Them, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_NhapLai, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_thoat, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(168, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_ThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ThemActionPerformed
        // TODO add your handling code here:

        //KIEM TRA INPUT
        if (txt_HotenNguoiGui.getText().compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Họ Tên Người Gửi Không Được Để Trống");
        }
        if (txt_SoCMNDNguoiGui.getText().compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Số CMND Người Gửi Không Được Để Trống");
        }
        if (txt_TenNguoiThuHuong.getText().compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Họ Tên Người Thụ Hưởng Không Được Để Trống");
        }
        if (txt_CMNDNguoiThuHuong.getText().compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Số CMND Người Thụ Hưởng Không Được Để Trống");
        }
        if (txt_SoTienGui.getText().compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Số Tiền Gửi Không Được Để Trống");
        }
        //gan ma so tiet kiem

        Deposit_DTO info = new Deposit_DTO();
        String str_FullName = txt_TenNguoiThuHuong.getText();
        String str_IDNumber = txt_CMNDNguoiThuHuong.getText();
        String str_TypeName = cbo_TenLoaiTietKiem.getSelectedItem().toString();
        String str_Term = cbo_KyHan.getSelectedItem().toString();
        String[] str_split = str_Term.split(" ");
        info.setDepositID("");
        try {
            info.setBookID(rsavingbook.GetBookID(str_FullName, str_IDNumber, str_TypeName, Integer.parseInt(str_split[0])));
            info.setCustomerName(txt_HotenNguoiGui.getText());
            info.setIDNumber(txt_SoCMNDNguoiGui.getText());
            info.setBeneficiaryName(txt_TenNguoiThuHuong.getText());
            info.setIDNumberBeneficiary(txt_CMNDNguoiThuHuong.getText());
            info.setDepositingDate(ConvertDateSQL(JXNgayMo));
            info.setAmountOfMoney(Integer.parseInt(txt_SoTienGui.getText()));
            //KIEM TRA 
            if (rcustomer.GetCustomerID(info.getCustomerName(), info.getIDNumber()).compareTo("") == 0) {
                JOptionPane.showMessageDialog(null, "Thông Tin Người Gửi Chưa Tồn Tại");
            } else {
                if (rcustomer.GetCustomerID(info.getBeneficiaryName(), info.getIDNumberBeneficiary()).compareTo("") == 0) {
                    JOptionPane.showMessageDialog(null, "Thông Tin Người Thụ Hưởng Chưa Tồn Tại");
                } else {
                    if (info.getAmountOfMoney() < rparamater.FindAll().getSoTienGuiThemToiThieu()) {
                        JOptionPane.showMessageDialog(null, "Số Tiền Gửi Thêm Phải >= " + rparamater.FindAll().getSoTienGuiThemToiThieu());
                    } else {
                        rdeposit.Insert(info);
                        JOptionPane.showMessageDialog(null, "Gửi Tiền Thành Công");
                        Unity.AddPanel(this, new JP_SavingBook());
                    }
                }
            }

        } catch (RemoteException ex) {
            Logger.getLogger(JP_Deposit.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(JP_Deposit.class.getName()).log(Level.SEVERE, null, ex);
        }


    }//GEN-LAST:event_btn_ThemActionPerformed

    private void btn_NhapLaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_NhapLaiActionPerformed
        // TODO add your handling code here:
        ClearAll();
    }//GEN-LAST:event_btn_NhapLaiActionPerformed

    private void btn_thoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_thoatActionPerformed
        try {
            // TODO add your handling code here:
            Unity.AddPanel(this, new JP_SavingBook());
        } catch (RemoteException ex) {
            Logger.getLogger(JP_Deposit.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(JP_Deposit.class.getName()).log(Level.SEVERE, null, ex);
        }
        this.setVisible(true);
    }//GEN-LAST:event_btn_thoatActionPerformed

    private void txt_SoCMNDNguoiGuiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_SoCMNDNguoiGuiKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!(Character.isDigit(c) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_SPACE)) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_SoCMNDNguoiGuiKeyTyped

    private void txt_HotenNguoiGuiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_HotenNguoiGuiKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (Character.isDigit(c)) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_HotenNguoiGuiKeyTyped

    private void txt_TenNguoiThuHuongKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_TenNguoiThuHuongKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if(Character.isDigit(c))
            evt.consume();
    }//GEN-LAST:event_txt_TenNguoiThuHuongKeyTyped

    private void txt_CMNDNguoiThuHuongKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_CMNDNguoiThuHuongKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!(Character.isDigit(c) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_SPACE)) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_CMNDNguoiThuHuongKeyTyped

    private void txt_SoTienGuiKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_SoTienGuiKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!(Character.isDigit(c) || c == KeyEvent.VK_BACK_SPACE || c == KeyEvent.VK_SPACE)) {
            evt.consume();
        }
    }//GEN-LAST:event_txt_SoTienGuiKeyTyped


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXDatePicker JXNgayMo;
    private javax.swing.JButton btn_NhapLai;
    private javax.swing.JButton btn_Them;
    private javax.swing.JButton btn_thoat;
    private javax.swing.JComboBox cbo_KyHan;
    private javax.swing.JComboBox cbo_TenLoaiTietKiem;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField txt_CMNDNguoiThuHuong;
    private javax.swing.JTextField txt_HotenNguoiGui;
    private javax.swing.JTextField txt_SoCMNDNguoiGui;
    private javax.swing.JTextField txt_SoTienGui;
    private javax.swing.JTextField txt_TenNguoiThuHuong;
    // End of variables declaration//GEN-END:variables
}
